<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="./vue.js"></script>
</head>
<body>
  <div id="app">  
      <input type="text" v-model="msg">
      <input type="text" v-model="obj.a">
      <input type="text" v-model="obj.b">
  </div>
  <script>
    let vm = new Vue({
      el:"#app",
      data:{
        msg:"",
        obj:{
          a:"",
          b:20
        }
      },
      watch:{
        msg(newVal,oldVal){
          console.log('值改变了，新值是'+newVal+"旧值是"+oldVal)
        },
        'obj.a'(newVal,oldVal){
          //console.log(newVal)
        },
        obj:{
          handler(newVal,oldVal){
            // 侦听器的函数
            console.log(newVal)
          },
          deep:true //深度监听
        }
      }
    })
  </script>
</body>
</html>